package main

import (
	"compress/location"
	"fmt"
	"os"
	"os/exec"
	"time"
)

func main() {
	for true {
		time.Sleep(3*time.Second)

		pid := location.GetPidFromFile()
		if pid <= 0 {
			fmt.Println("pid < 0,启动")
			run();
			continue
		}
		_,err := os.FindProcess(pid)
		if err != nil  {
			fmt.Println(err)
			run();
			continue
		}
	}
}

func run () {
	cmd := exec.Command("main.exe")
	out, err := cmd.CombinedOutput()
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(string(out))
}
